// pages/index/index.js
Page({
  data: {
    active: 0,
    tab: 'index',
    tabBar: {
      list: [{
          pagePath: "pages/index/index",
          text: "首页",
          code: "index",
          icon:"home-o"
        },
        {
          pagePath: "pages/order/order",
          text: "点餐",
          code: "cook",
          icon:"cart-o"
        },
        {
          pagePath: "pages/records/records",
          text: "订单",
          code: "order",
          icon:"orders-o"
        },
        {
          pagePath: "pages/profile/profile",
          text: "我的",
          code: "my",
          icon: "user-o"
        }
      ]
    }
  },

  // 切换服务类型
  onServiceChange(event) {
    const service = event.currentTarget.dataset.service;
    wx.showToast({
      title: `已选择：${service === 'pickup' ? '到店自取' : '外卖到家'}`,
      icon: 'none'
    })
  },

  barChange(e){
    console.log(e.detail);
    this.setData( {
      active:e.detail,
      tab:this.data.tabBar.list[e.detail].code
    } )
  }
})